<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<fmt:setLocale value="${currentLocale}"/>
<fmt:setBundle basename="messages"/>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link type="text/css" rel="stylesheet" href="../style/style.css"/>
<title><fmt:message key="allsongs.title"/></title>
</head>
<body>
<%@ include file="../simple/navbar.jsp" %>
<%@ include file="../simple/filters.jsp" %>


<div class="content">
<h1><fmt:message key="allsongs.title"/></h1>

<p><small><c:forEach items="${offsets}" var="offset">
<c:url value="../simple/all-songs.html" var="offseturl">
<c:param name="offset" value="${offset}"/>
</c:url>
<c:if test="${currentOffset != offset}">
<a href="<c:out value="${offseturl}"/>"><c:out value="${offset+1}"/>-<c:out value="${offset+2}"/></a>&nbsp;&nbsp;
</c:if>
<c:if test="${currentOffset == offset}">
<b><c:out value="${offset+1}"/>-<c:out value="${offset+2}"/></b>&nbsp;&nbsp;
</c:if>
</c:forEach></small></p> 

<table>
<c:forEach items="${songs}" var="song" varStatus="status">
<c:url value="../simple/view-song.html" var="viewSongUrl">
<c:param name="label" value="${song.label}"/>
</c:url>
<c:url value="../admin/edit-song.html" var="editSongUrl">
<c:param name="label" value="${song.label}"/>
</c:url>
<c:url value="../admin/delete-ask.html" var="deleteSongUrl">
<c:param name="label" value="${song.label}"/>
</c:url>


<tr>
<td><c:out value="${status.count}" />. <a href="<c:out value="${viewSongUrl}"/>"><c:out
value="${song.title}" escapeXml="false" /></a></td>
<% if (user != null && userService.isUserAdmin()) { %> 
<td><a href="<c:out value="${editSongUrl}" />">Edit</a></td>
<td><a href="<c:out value="${deleteSongUrl}" />">Delete</a></td>
<% } %>
</tr>
</c:forEach>
</table>

<% if (user != null && userService.isUserAdmin()) { %> 
<p style="font-size:120%;font-weight=bold"><a href="../admin/new-song.html">Jauna dziesma</a></p>

<% } %>

<p><small>Total songs: <c:out value="${count}"/></small></p>
</div>

</body>
</html>